#ifndef __COMPACTCORE_H_
#define __COMPACTCORE_H_

#include <cstdlib>
#include "GAcore.hpp"
#include "GAmodSettings.hpp"
#include "common.hpp"
#include "CompactPop.hpp"
#include "popolazione.hpp"


class CompactCoreException : public GAcoreException
{
    public:
    CompactCoreException(char *mess) : GAcoreException(mess) {};
};

/** \class CompactCore
 *  \brief It implements a genetic algorithm based on a compact rapresentation of the population, with a probabilistic vector.
 */

class CompactCore : public GAcore 
{
	public:
	
	    enum params {
        PARAM_ALL           = 0xFFFFFFFF,       //!< Calcola tutti i parametri
        PARAM_HAM_BEST      = 0x00000020,       //!< Calcola distanza di hamming dall'individuo migliore
        PARAM_N_CROSS       = 0x00000010,       //!< Calcola il numero di crossover (per generazione) nell'ultima chiamata a \c run_generation
        PARAM_N_MUT         = 0x00000008,       //!< Calcola il numero di mutazioni per individuo (per generazione) nell'ultima chiamata a \c run_generation
        PARAM_VAR_SCORE     = 0x00000004,       //!< Varianza del valore di fitness su tutta la popolazione
        PARAM_MEAN_SCORE    = 0x00000002,       //!< Fitness medio
        PARAM_BEST_SCORE    = 0x00000001        //!< Best score
    };
	
    protected:

		// - the parameter D that modify the compact population (size of modification)
		float d;
		// - the "fuzzy margin", probability of 1 never greater than 1-t, or lower than t.
		float t;
		/* the compact rapresentation of the population*/
		CompactPop * P;
		/* the extender rapresentation of the population, for the evaluation*/
		Popolazione *M;
		
    public:
		//implementations of the virtual GAcore methods
		CompactCore(Validator *val,GAmodSettings &settings) throw(CompactCoreException);
		int loadSettings(GAmodSettings &settings,load_exc le = GAcore::THROW_EXCEPTION) throw(CompactCoreException);
		int getGenerationData(GAmodSettings &settings,HERAuint32 lista = 0);
		int runGeneration(int num);
		/*
		 *
		 *To get a fake population with the last two individuals
		 */
		void getPopolazione(Popolazione &p);
		

		
};
#endif